<template>
	<view class="app">
		<view class="price-box">
			<text>支付金额</text>
			<text class="price">{{amount}}</text>
		</view>

		<view class="pay-type-list">
			<view class="type-item b-b" @click="changePayType(1)">
				<text class="icon yticon icon-weixinzhifu"></text>
				<view class="con">
					<text class="tit">微信支付</text>
					<text>推荐使用微信支付</text>
				</view>
				<label class="radio">
					<radio value="" color="#fa436a" :checked='payType == 1' />
					</radio>
				</label>
			</view>
			<!-- #ifndef MP-WEIXIN -->
			<view class="type-item b-b" @click="changePayType(3)" v-if="!isWechat">
				<text class="icon yticon icon-alipay"></text>
				<view class="con">
					<text class="tit">支付宝支付</text>
				</view>
				<label class="radio">
					<radio value="" color="#fa436a" :checked='payType == 3' />
					</radio>
				</label>
			</view>
			<!-- #endif -->
			<!-- #ifdef H5 -->
			<!-- <view class="type-item b-b" @click="changePayType(5)" v-if="group==0&&!isWechat">
				<text class="icon yticon icon-erjiye-yucunkuan"></text>
				<view class="con">
					<text class="tit">预存款支付</text>
					<text>可用余额 ¥{{money}}</text>
				</view>
				<label class="radio">
					<radio value="" color="#fa436a" :checked='payType == 5' />
					</radio>
				</label>
			</view> -->
			<!-- #endif -->
			<view class="type-item b-b" @click="changePayType(6)" v-if="ORDERNUM.substring(0,1)!='Z'">
				<text class="icon yticon icon-erjiye-yucunkuan"></text>
				<view class="con">
					<text class="tit">余额支付</text>
					<text>可用余额 ¥{{money}}</text>
				</view>
				<label class="radio">
					<radio value="" color="#fa436a" :checked='payType == 6' />
					</radio>
				</label>
			</view>
			
			
			<view class="un-geng" v-if="isWechat">
				<view class="">更多支付方式，</view>
				<view class="">请点击右上角 ···，选择 在浏览器打开</view>
				<view class="">进行支付</view>
			</view>
			
	
			<!-- <view class="type-item1 b-b" @click="changePayType(4)" :class="{typeitem1:payType === 4}">
				<text class="icon iconfont icon-yinhangqia"></text>
				<view class="con">
					<text class="tit">银行卡支付</text>
				</view>
				<label class="radio">
					<radio value="" color="#fa436a" :checked='payType == 4' />
					</radio>
				</label>
				<view v-if="payType == 4" class="clamp un-c">
					<view v-if="cardlist!==''">
						<view >
							<text class="un-t iconfont icon-arrLeft-fill"></text>
							<text class="un-t1">使用此卡支付</text>
						</view>
						<view class="clamp un-card">
							<view >
								<text class="clamp un-text1">{{cardlist.BANKNAME}}</text>
								<text class="clamp un-text2">{{cardlist.CARDTYPE}}</text>
								<text class="clamp un-text1">**** **** **** {{cardlist.CARDNO}}</text>
							</view>
							<text class="iconfont icon-youjiantou un-icon" @click="chooseCard"></text>
						</view>
					</view>
					<view  v-if="cardlist===''" @click="navToaddbankcard">
						<view >
							<text class="un-t2 iconfont icon-arrLeft-fill"></text>
						</view>
						<view class="un-card1">
							<text class="yticon icon-jia1">添加银行卡</text>
						</view>
					</view>
				</view>
			</view> -->
		</view>
		<uni-popup  :show="type1=='one'" type="middle" >
			<form class="form1"  @submit="formSubmit1">
				<!-- 登录form -->
				<view class="login_form">
					<view class="pwd">请输入支付密码</view>
					<view class="input">
						<input type="password" name="newpwd" :value="newpwd1"   placeholder="支付密码">
					</view>
				</view>
				<!-- 登录提交 -->
				<button class="submit" type="primary"  formType="submit" >确定</button>
				<view class="yticon icon-fork badge" @click="togglePopup('')"></view>
			</form>
		</uni-popup>
		
		
		<view class="" v-if="zhifu!==''">
			<web-view  :webview-styles="webviewStyles" :src="zhifu"></web-view>
		</view>
		 <!-- #ifdef H5 -->
		 <text v-if="!isWechat" class="mix-btn" @click="pay">确认支付</text>
		  <text v-else class="mix-btn" @click="pay3">确认支付</text>
		 <!-- #endif -->
		 <!-- #ifdef MP-WEIXIN -->
		 <text class="mix-btn" @click="pay1">确认支付</text>
		 <!-- #endif -->
		 <!-- #ifdef APP-PLUS -->
		 <text class="mix-btn" @click="pay2">确认支付</text>
		 <!-- #endif -->
	</view>
</template>

<script>
	import { mapMutations  } from 'vuex';
	import uniPopup from '@/components/uni-popup/uni-popup.vue';
	var  graceChecker = require("../../common/graceChecker.js");
	// #ifdef H5
	var jweixin = require('../../common/jweixin-1.4.0.js');
	// #endif
	export default {
		components: {
			uniPopup,
		},
		data() {
			return {
				payType: 0,
				orderInfo: {},
				amount : 0,
				ORDERNUM: '',
				money : '',
				type1: '',
				newpwd1:'',
				cardlist:'',
				card:{},
				time: '',
				length: '',
				code:true,
				zhifu:'',
				webviewStyles: {
					progress: {
						color: '#FF3333'
					}
				},
				group: 0,
				car : 0,
				isWechat:false
			};
		},
		onLoad(options) {
			this.ORDERNUM = options.ORDERNUM;
			this.amount = options.AMOUNT;
			if(options.group == 1){
				this.group = 1
			}
			if(options.check==1){
				this.loadCheck()
			}
			
			this.loadDate()
			uni.startPullDownRefresh();
			// #ifdef H5
			console.log('isWechat():', isWechat(),options);
			if (isWechat()) {
				this.isWechat=true;
				//如果为微信端就进行code
				this.getCode();
				getConfig()
			}
			// #endif
			
		},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		computed: {
			name() {
				return this.payType 
			},
		},
		watch:{
			payType(newV,oldV){
				if(newV === 4){
					this.loadCard();
				}
			}
		},
		
		onShow(){
			if(this.payType === 4){
				this.loadCard();
			}
		},
		methods: {
			onBackPress(options) {
				console.log('from:' + options.from)
				if (options.from == 'backButton') {
					console.info(111)
					if(this.zhifu!=''){
						if(this.group == 1){
							uni.redirectTo({
								url:'/pages/money/paySuccess?ORDERNUM='+this.ORDERNUM+'&ISBACK=1&group=1'
							})
						}else{
							uni.redirectTo({
								url:'/pages/money/paySuccess?ORDERNUM='+this.ORDERNUM+'&ISBACK=1'
							})
							
						}
					
					}
					return true; 
				}
			},
			
			 async loadCard(){
				this.$http.post("/user/defaultCard",{
					SIGNATURE : uni.getStorageSync('SIGNATURE'),
					TOKEN: uni.getStorageSync('userInfo').TOKEN,
				}).then((e)=>{
					
					 if (e.statusCode === 200 && e.data.STATE === '0') {  
						this.cardlist = e.data.OBJECT;
						this.length = this.cardlist.CARDNO.length;
						this.cardlist.CARDTYPE = this.cardlist.CARDTYPE === '1' ?  '借记卡' : '贷记卡';
						this.cardlist.CARDNO = this.cardlist.CARDNO.substr(this.length-4,4);
						console.log("******",this.cardlist);
				    }else if(e.data.MSG === '没有绑定的银行卡'){
						uni.showModal({
								content: '没有绑定，现在去绑定？',
								success: (res)=>{
									if(res.confirm){
											uni.navigateTo({
												url:`/pages/bankcard/addbankcard/addbankcard`
											})
										}
									},
								})
					}
				})
				.catch((err)=>{
					console.log('request fail', err);
				})
			},
			
			loadCheck(){
				let SIGNATURE = uni.getStorageSync("SIGNATURE");
				var  uri = ''
				if(this.group == 1){
					uri = "/group/query"
				}else{
					uri = "/order/query"
				}
				this.$http.post(uri,{
						SIGNATURE : SIGNATURE,
						ORDERNUM : this.ORDERNUM,
						TOKEN: uni.getStorageSync("userInfo").TOKEN,
						TOKENP:uni.getStorageSync("userInfo").TOKENP,
					}).then((e)=>{
						if(e.data.STATE === '0' && e.statusCode === 200){
							console.log(">>>>>>>>>>>>>>>>>>>>>>",e)
							if(e.data.OBJECT.PAYSTATE === 1){
								uni.showModal({
									content: '该笔订单已经支付',
									success: (res)=>{
										if(res.confirm){
											uni.switchTab({
												url: '/pages/user/user'
											})
										}else if(res.cancel) {
											uni.switchTab({
												url: '/pages/user/user'
											})
										}
									},
								})
							}
							
						}
					}).catch((err)=>{
						console.log('request fail', err);
					})
				
			},
			async loadDate(){
				this.$http.post("/user/info",{
					SIGNATURE : uni.getStorageSync('SIGNATURE'),
					TOKEN: uni.getStorageSync('userInfo').TOKEN,
				}).then((e)=>{
					 if (e.statusCode === 200 && e.data.STATE === '0') {  
						this.money = e.data.OBJECT.MONEY;
				    }  
				})
				.catch((err)=>{
					console.log('request fail', err);
				})
			},
			//选择支付方式
			changePayType(type) {
				this.payType = type
				console.log(">>>>>>>",type)
				if(type == 6){
					//是否需要强制修改支付密码
					this.$http.post('/user/findFirst',{
						SIGNATURE : uni.getStorageSync("SIGNATURE"),
						TOKEN: uni.getStorageSync("userInfo").TOKEN,
					}).then((res)=>{
						if(res.data.STATE == '903'||res.data.STATE == '904'){
							uni.navigateTo({
								url:'/pages/public/login1'
							})
						}else if(res.data.STATE === "0" && res.statusCode === 200){
							if(res.data.OBJECT == 0){
								//首次登录  提示+
								uni.showModal({
									content: '商品已为您加入未付款订单，由于您还没有设置支付信息，请先去 我的->资金管理 设置',
									success: (res)=>{
										if(res.confirm){
											uni.switchTab({
												url:"/pages/user/user"
											})
										}else if(res.cancel) {
											uni.navigateBack({
												delta:2
											})
										}
									},
								})
							}
						}
					})
					.catch((err)=>{
					    console.log('request fail', err);
					})
				}else if(type == 1){
					
				}
			
				
			},
			//添加银行卡
			navToaddbankcard(){
				uni.navigateTo({
					url:`/pages/bankcard/addbankcard/addbankcard`
				})
			},
			//选择银行卡
			chooseCard(){
				uni.navigateTo({
					url: '/pages/bankcard/bankcard'
				})
			},
			//弹框
			togglePopup(type) {
				if(type==''){
					this.newpwd1 = ''
				}
				this.type1 = type
				// this.type = type;
			},
			formSubmit1(e){
				var rule = [];
				//进行表单检查
				var formData = e.detail.value;
				var checkRes = graceChecker.check(formData, rule);
				if(checkRes){
					this.$http.post('/user/loginPay',{
						SIGNATURE : uni.getStorageSync("SIGNATURE"),
						TOKEN: uni.getStorageSync("userInfo").TOKEN,
						PWD:e.detail.value.newpwd,
					}).then((res1)=>{
						if(res1.data.STATE == '903'||res1.data.STATE == '904'){
							uni.navigateTo({
								url:'/pages/public/login1'
							})
						}
						//判断返回内容
						if(res1.data.STATE === "0" && res1.statusCode === 200){
							this.togglePopup('')
							this.car = 1
							// #ifdef H5
							if(!this.isWechat){
								this.pay()
							}else{
								this.pay3()
							}
							// #endif
							//#ifdef MP-WEIXIN
							this.pay1()
							//#endif
							//#ifdef APP-PLUS
							this.pay2()
							//#endif
							console.log(">>>>>>>>>>",this.type1)
							
						}else{
							uni.showToast({title:res1.data.MSG, icon:"none"});
						}
					})
					.catch((err1)=>{
						console.log('request fail', err1);
					})
				}else{
					uni.showToast({ title: graceChecker.error, icon: "none" });
				}
			},
			pay(){
				if(this.payType==''){
					uni.showToast({
						title: '请选择支付方式',
						icon: "none",
					})
				}else if(this.payType==6&&this.car!=1){
						this.type1="one"
				}else {
					uni.showLoading({
						title:'请稍候...'
					})
					var count = 0
					if(this.payType==1){
						count = 1
						//#ifdef H5						
						window.navigator.userAgent
						var co = window.navigator.userAgent.match(/MicroMessenger/i)
						if(window.navigator.userAgent.match(/MicroMessenger/i) == "MicroMessenger"){
							
							count = 0
							uni.showModal({
								content: '请点击右上角···,选择 在浏览器打开进行支付',
								success: (res)=>{
									if(res.confirm){
										
									}else if(res.cancel) {
										
									}
								},
							})
						}
						//#endif
					}
					if(this.payType==5 || count == 1 ||this.payType==3||this.payType==6){
						var  uri = ''
						if(this.payType==5 && this.car == 0){
							this.togglePopup('one')
							uni.hideLoading()
							return
						}
						if(this.group == 1){
							uri = "/group/pay"
						}else{
							uri = "/order/pay"
						}
						this.$http.post(uri,{
							SIGNATURE : uni.getStorageSync('SIGNATURE'),
							TOKEN: uni.getStorageSync('userInfo').TOKEN,
							TOKENP: uni.getStorageSync('userInfo').TOKENP,
							ORDERNUM: this.ORDERNUM,
							FLAG: this.payType,
						}).then((e)=>{
							console.log(">>>>>>>>>>>>>",e);
							uni.hideLoading()
							if(e.data.STATE == '903'||e.data.STATE == '904'){
								// #ifdef MP-WEIXIN
								uni.showModal({
									content:'请重新登录',
									success: function (res) {
									        if (res.confirm) {
									            uni.switchTab({
									            	url:"/pages/user/user"
									            })
									        } else if (res.cancel) {
									            console.log('用户点击取消');
									        }
									    }
								})
								// #endif
								// #ifndef MP-WEIXIN
								uni.navigateTo({
									url:'/pages/public/login1'
								})
								// #endif
								
							}else if((e.statusCode === 200) && (e.data.STATE === '0')){
								if(this.payType == 5){
									this.zhifu = e.data.OBJECT
								}else if(this.payType == 1){
									// this.zhifu = e.data.OBJECT.URL
									// #ifdef H5
									window.location.href = e.data.OBJECT.URL
									// #endif
								}else if(this.payType == 3){
									// #ifdef H5
									const div = document.createElement('div');
									div.innerHTML = (e.data.OBJECT.URL);  
									document.body.appendChild(div);
									document.forms[0].submit();
									// #endif
									console.log("H5支付宝支付返回的",e.data.OBJECT)
								}else if(this.payType == 6){
									// #ifdef H5
									uni.showToast({
										title:"支付成功",
										icon:"none"
									})
									uni.redirectTo({
										url:"/pages/money/paySuccess?ORDERNUM="+this.ORDERNUM+"&TYPE="+this.payType
									})
									// #endif
									console.log("H5余额支付返回的",e.data.OBJECT)
								}
							}else if((e.statusCode === 200) && (e.data.STATE === '-1')){
								
								uni.showToast({
									title: e.data.MSG,
									icon: "none",
								})
								
							}else{
								uni.showToast({
									title: e.data.MSG,
									icon: "none",
								})
							}
						})
						.catch((err)=>{
							console.log('request fail', err);
							
						})
					}
					
				}
			},
			//微信小程序支付
			pay1(){
				if(this.payType==''){
					uni.showToast({
						title: '请选择支付方式',
						icon: "none",
					})
				}else if(this.payType==6&&this.car!=1){
						this.type1="one"
				}else {
					uni.showLoading({
						title:'请稍候...'
					})
						var  uri = ''
						if(this.group == 1){
							uri = "/group/pay1"
						}else{
							uri = "/order/pay1"
						}
						this.$http.post(uri,{
							SIGNATURE : uni.getStorageSync('SIGNATURE'),
							TOKEN: uni.getStorageSync('userInfo').TOKEN,
							ORDERNUM: this.ORDERNUM,
							OPENID:uni.getStorageSync('OPENID'),
							FLAG: this.payType,
						}).then((e1)=>{
							console.log(">>>>>>>>>>>>>",e1);
							uni.hideLoading()
							if(e1.data.STATE == '903'||e1.data.STATE == '904'){
								uni.showToast({
									title:"请重新登录",
									icon:"none"
								})
								
							}
							if((e1.statusCode === 200) && (e1.data.STATE === '0')){
								if(this.payType == 1){
									uni.requestPayment({
									    provider: 'wxpay',
									    timeStamp: e1.data.OBJECT.TIMESTAMP,
									    nonceStr: e1.data.OBJECT.NONCESTR,
									    package: e1.data.OBJECT.PACKAGE,
									    signType: 'MD5',
									    paySign: e1.data.OBJECT.SIGN,
									    success: function (res) {
									        console.log('success:' + JSON.stringify(res));
											uni.redirectTo({
												url:'/pages/money/paySuccess?ORDERNUM='+e1.data.OBJECT.ORDERNUM
											})
									    },
									    fail: function (err) {
									        console.log('fail:' + JSON.stringify(err));
									    }
									});
								}else if(this.payType == 6){
									uni.showToast({
										title:"支付成功",
										icon:"none"
									})
									uni.redirectTo({
										url:"/pages/money/paySuccess?ORDERNUM="+this.ORDERNUM
									})
								}
								
							}else if((e1.statusCode === 200) && (e1.data.STATE === '-1')){
									
										uni.showToast({
											title: e1.data.MSG,
											icon: "none",
										})
								
							}else{
								uni.showToast({
									title: e1.data.MSG,
									icon: "none",
								})
							}
						})
						.catch((err)=>{
							console.log('request fail', err);
							
						})
					}
					
			},
			//APP支付
			pay2(){
				if(this.payType==''){
					uni.showToast({
						title: '请选择支付方式',
						icon: "none",
					})
				}else if(this.payType==6&&this.car!=1){
						this.type1="one"
				}else {
					uni.showLoading({
						title:'请稍候...'
					})
					var  uri = ''
					if(this.group == 1){
						uri = "/group/pay2"
					}else{
						uri = "/order/pay2"
					}
					this.$http.post(uri,{
						SIGNATURE : uni.getStorageSync('SIGNATURE'),
						TOKEN: uni.getStorageSync('userInfo').TOKEN,
						ORDERNUM: this.ORDERNUM,
						OPENID:uni.getStorageSync('OPENID'),
						FLAG:this.payType,
						}).then((e2)=>{
							console.log(">>>>>>>>>>>>>",e2);
							uni.hideLoading()
							if(e2.data.STATE == '903'||e2.data.STATE == '904'){
								uni.showToast({
									title:"请重新登录",
									icon:"none"
								})
								
							}
							if((e2.statusCode === 200) && (e2.data.STATE === '0')){
								if(this.payType == 6){
									uni.showToast({
										title:"支付成功",
										icon:"none"
									})
									uni.redirectTo({
										url:"/pages/money/paySuccess?ORDERNUM="+this.ORDERNUM
									})
								}else{
									uni.requestPayment({
										 provider: e2.data.OBJECT.PROVIDER,
										 orderInfo:e2.data.OBJECT.ORDERINFO , //微信、支付宝订单数据
										success: function (res) {
											console.log('success:' + JSON.stringify(res));
											uni.redirectTo({
												url:'/pages/money/paySuccess?ORDERNUM='+e2.data.OBJECT.ORDERNUM
											})
										},
										fail: function (err) {
											console.log('fail:' + JSON.stringify(err));
										}
									});
								}
								
							}else if((e2.statusCode === 200) && (e2.data.STATE === '-1')){
										uni.showToast({
											title: e2.data.MSG,
											icon: "none",
										})
								
							}else{
								uni.showToast({
									title: e2.data.MSG,
									icon: "none",
								})
							}
						})
						.catch((err)=>{
							console.log('request fail', err);
							
						})
				}
			},
			// #ifdef H5
			//获取微信公众号code
			getCode() {
				let appid = "wx0f9f6f7937087278"; //为测试号id
				let code = getUrlParam("code"); //是否存在code
				console.log(code);
				let local =window.location.href;
				if (code == null || code === "") {
					//不存在就打开上面的地址进行授权
					window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_base&state=1#wechat_redirect`;
				} else {
					console.log("获取code",code)
					
					if(!uni.getStorageSync('POPENID')){
						this.$http.post("/user/publicOpenId",{
							SIGNATURE : uni.getStorageSync('SIGNATURE'),
							TOKEN: uni.getStorageSync('userInfo').TOKEN,
							CODE:code,
						}).then((e)=>{
							 if (e.statusCode === 200 && e.data.STATE === '0'&&e.data.OBJECT!=null) {
									  uni.setStorageSync("POPENID",e.data.OBJECT);
						    }  else{
								uni.showToast({
									title:"请重新登录",
									icon:"none"
								})
								console.log("获取公众OPENID失败",e)
							}
						})
						.catch((err)=>{
							console.log('request fail', err);
						})
					}
					
				}
			},
			//微信公众号支付
			pay3(){
				if(this.payType==''){
					uni.showToast({
						title: '请选择支付方式',
						icon: "none",
					})
				}else if(this.payType==6&&this.car!=1){
						this.type1="one"
				}else {
					uni.showLoading({
						title:'请稍候...'
					})
						var  uri = ''
						if(this.group == 1){
							uri = "/group/pay3"
						}else{
							uri = "/order/pay3"
						}
						this.$http.post(uri,{
							SIGNATURE : uni.getStorageSync('SIGNATURE'),
							TOKEN: uni.getStorageSync('userInfo').TOKEN,
							ORDERNUM: this.ORDERNUM,
							OPENID:uni.getStorageSync('POPENID'),
							FLAG: this.payType,
						}).then((e1)=>{
							console.log(">>>>>>>>>>>>>",e1);
							uni.hideLoading()
							if(e1.data.STATE == '903'||e1.data.STATE == '904'||e1.data.STATE == '905'||e1.data.STATE == '906'||e1.data.STATE == '907'){
								uni.showToast({
									title:"请重新登录",
									icon:"none"
								})
								
							}else if((e1.statusCode === 200) && (e1.data.STATE === '0')){
								if(this.payType == 1){
									function onBridgeReady(){
									   WeixinJSBridge.invoke(
										  'getBrandWCPayRequest', {
											 "appId":e1.data.OBJECT.APPID,     //公众号名称，由商户传入     
											 "timeStamp":e1.data.OBJECT.TIMESTAMP,         //时间戳，自1970年以来的秒数     
											 "nonceStr":e1.data.OBJECT.NONCESTR, //随机串     
											 "package":e1.data.OBJECT.PACKAGE,     
											 "signType":"MD5",         //微信签名方式：     
											 "paySign":e1.data.OBJECT.SIGN, //微信签名 
										  },
										  function(res){
										  if(res.err_msg == "get_brand_wcpay_request:ok" ){
										  // 使用以上方式判断前端返回,微信团队郑重提示：
												//res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
												console.log('success:' + JSON.stringify(res));
												uni.redirectTo({
													url:'/pages/money/paySuccess?ORDERNUM='+e1.data.OBJECT.ORDERNUM
												})
										  } 
									   }); 
									}
									if (typeof WeixinJSBridge == "undefined"){
									   if( document.addEventListener ){
										   document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
									   }else if (document.attachEvent){
										   document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
										   document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
									   }
									}else{
									   onBridgeReady();
									}
									
								}else if(this.payType == 6){
									uni.showToast({
										title:"支付成功",
										icon:"none"
									})
									uni.redirectTo({
										url:"/pages/money/paySuccess?ORDERNUM="+this.ORDERNUM+"&TYPE=6"
									})
								}
								
							}else{
								uni.showToast({
									title: e1.data.MSG,
									icon: "none",
								})
							}
						})
						.catch((err)=>{
							console.log('request fail', err);
							
						})
					}
					
			},
			// #endif
			
			
			
			//获取验证码
			// getCode(val) {
			// 	console.log(val);
			// 	this.togglePopup('');
			// 	uni.showLoading({
			// 		title: '支付中...'
			// 	});
			// 	let SIGNATURE = uni.getStorageSync('SIGNATURE');
			// 	this.$http.post("/order/pay",{
			// 		SIGNATURE : SIGNATURE,
			// 		TOKEN: uni.getStorageSync('userInfo').TOKEN,
			// 		ORDERNUM: this.ORDERNUM,
			// 		FLAG: this.payType,
			// 		SQPayMethod : '2',
			// 		CODE: val,
			// 		TIME: this.time,
			// 	}).then((e)=>{
			// 		console.log(e);
			// 		uni.hideLoading();
			// 		this.togglePopup('');
			// 		if((e.statusCode === 200) && (e.data.STATE === '0')){
			// 			uni.redirectTo({
			// 				url: '/pages/money/paySuccess?ORDERNUM='+this.ORDERNUM
			// 			})
			// 		}else{
			// 			uni.showToast({
			// 				title: e.data.MSG,
			// 				icon: "none",
			// 			})
			// 			this.togglePopup('middle-img');
			// 		}
			// 	})
			// 	.catch((err)=>{
			// 		console.log('request fail', err);
			// 		
			// 	})
			// 	
			// },
			//确认支付
// 			confirm: async function() {
// 				if(this.payType===4&&this.cardlist!==null){
// 					this.togglePopup('middle-img');
// 				}
// 
// 				let SIGNATURE = uni.getStorageSync('SIGNATURE');
// 				this.$http.post("/order/pay",{
// 					SIGNATURE : SIGNATURE,
// 					TOKEN: uni.getStorageSync('userInfo').TOKEN,
// 					ORDERNUM: this.ORDERNUM,
// 					FLAG: this.payType,
// 					SQPayMethod : '1'
// 				}).then((e)=>{
// 					if((e.statusCode === 200) && (e.data.STATE === '0')){
// 						this.time = e.data.OBJECT.TIME;
// 						if(this.payType===4 && this.cardlist!==null){
// 							this.togglePopup('middle-img');
// 						}
// 					}else{
// 						uni.showToast({
// 							title: "信息有误,发送失败",
// 							icon: "none",
// 						})
// 					}
// 				})
// 				.catch((err)=>{
// 					console.log('request fail', err);
// 				})
// 				
// 			},
			
		},
	
		
	}
	// #ifdef H5
	// 判断公众号截取code
	const getUrlParam = (name) => {
		let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		let r = window.location.search.substr(1).match(reg);
		if (r != null) {
			return unescape(r[2]);
		}
		return null;
	}
	
	// 判断是否为公众号模拟器环境
	const isWechat = () => {
		return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
	}
	
	//获取微信公众号的配置
	const getConfig=()=>{
		uni.request({
			url: getApp().globalData.http+'/common/getConfig', //仅为示例，并非真实接口地址。
			data: {
				SIGNATURE : uni.getStorageSync('SIGNATURE'),
				URL:window.location.href,
			},
			header: {
				'content-type':'application/x-www-form-urlencoded',
			},
			success: (s) => {
				console.log(s);
				jweixin.config({
					 debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
					 appId: s.data.OBJECT.APPID, // 必填，公众号的唯一标识
					 timestamp: s.data.OBJECT.TIMESTAMP, // 必填，生成签名的时间戳
					 nonceStr: s.data.OBJECT.NONCESTR, // 必填，生成签名的随机串
					 signature: s.data.OBJECT.SIGNATURE, // 必填，签名，见附录1
					 jsApiList: ["chooseWXPay"]
				});	
			}
		})
		jweixin.ready(function(){
		// TODO
			
		})
	}
	// #endif
	
</script>

<style lang='scss'>
	.app {
		width: 100%;
	}
	.form1{
		background-color: #f5f5f5;
		width: 450upx;
		height: 300upx;
		border-radius: 8%;
		border: 2upx solid #9F9F9F;
		.login_form{
			margin: 20upx;
			padding-left: 30upx;
			padding-right: 30upx;
			.pwd{
				font-size: 35upx;
				font-weight: 900;
				text-align: center;
			}
			.input{
				border: 1upx solid #9F9F9F;
				margin: 40upx 0upx 20upx 0upx;
				height: 60upx;
			}
		}
		.submit{
			background-color: #E02E24;
			width: 80%;
		}
		.yticon{
			position: absolute;
			top: 70upx;
			left: 400upx;
			color: #EBEDF0;
			background-color: #999999;
			border-radius: 100%;
		}
	}
	.price-box {
		background-color: #fff;
		height: 265upx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		font-size: 28upx;
		color: #909399;

		.price{
			font-size: 50upx;
			color: #303133;
			margin-top: 12upx;
			&:before{
				content: '￥';
				font-size: 40upx;
			}
		}
	}

	.pay-type-list {
		margin-top: 20upx;
		background-color: #fff;
		padding-left: 60upx;
		
		.type-item{
			height: 120upx;
			padding: 20upx 0;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding-right: 60upx;
			font-size: 30upx;
			position:relative;
			
		}
		.type-item1{
			height: 120upx;
			padding: 20upx 0;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding-right: 60upx;
			font-size: 30upx;
			position:relative;
			.un-c{
				position: absolute;
				top:80upx;
				.un-t{
					position: absolute;
					color: #f5f5f5;
					top: -20upx;
					left: 510upx;
					font-size: 80upx;
					
				}
				.un-t1{
					margin-left: 30upx;
					font-size: $font-sm;
					color: $font-color-light;
				}
				.un-card{
					
					height: 110upx;
					
					padding: 5upx 30upx;
					display: flex;
					background-color: #f5f5f5;
					.un-text1{
						font-size: 28upx;
						color: #666666;
					}
					.un-text2{
						font-size: 24upx;
						color: #999999;
					}
					.un-icon{
						margin: 30upx 30upx 0upx 300upx;
					}
					
				}
				.un-t2{
					position: absolute;
					color: #f5f5f5;
					top: -22upx;
					left: 510upx;
					font-size: 80upx;
				}
				.un-card1{
					height: 110upx;
					width: 650upx;
					text-align: center;
					padding: 5upx 30upx;
					display: flex;
					background-color: #f5f5f5;
					margin-top: 30upx;
					text{
						color: #999999;
						margin: 20upx 30upx;
						font-size: 30upx;
					}
				}
			}
			
			
		}
		.typeitem1{
			height: 240upx;
			align-items: stretch;
		}
		
		.icon{
			width: 100upx;
			font-size: 52upx;
		}
		.icon-erjiye-yucunkuan {
			color: #fe8e2e;
		}
		.icon-weixinzhifu {
			color: #36cb59;
		}
		.icon-alipay {
			color: #01aaef;
		}
		.icon-yinhangqia{
			color: #786eff;
		}
		.tit{
			font-size: $font-lg;
			color: $font-color-dark;
			margin-bottom: 4upx;
		}
		.con{
			flex: 1;
			display: flex;
			flex-direction: column;
			font-size: $font-sm;
			color: $font-color-light;
		}
		
	}
	.mix-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 630upx;
		height: 80upx;
		margin: 80upx auto 30upx;
		font-size: $font-lg;
		color: #fff;
		background-color: $base-color;
		border-radius: 10upx;
		box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
	}
	
	.un-center-box{
		background-color: #fff;
		border: 2upx solid #9D9D9D;
		border-radius: 5%;
		width:600upx;
		height: 300upx;
		margin:0 30upx;
		text-align: center;
		.un-ling{
			background-color: #E02E24;
			width: 100%;
			height: 123upx;
			color: #FFFFFF;
			text-align: center;
			line-height: 123upx;
			font-size: 38upx;
			font-family: '微软雅黑 Bold', '微软雅黑 Regular', '微软雅黑';
			font-weight: 700;
			font-style: normal;
			margin-bottom: 20upx;
		}
		.badge{
			position:absolute;
			top:50upx;
			right:50upx;
			color: #FFFFFF;
			display:flex;
			font-size: 38upx;
		}
	
	}
	.un-geng{
		align-items: center;
		text-align: center;
		color: #999999;
		font-size: 28upx;
		line-height: 40upx;
		margin-top: 50upx;
	}
</style>
  